<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #er {
            display: block;
            width: 200px;
        }

        .btn {
            background-color: transparent;
        }

        .box {
            margin: 100px auto;
        }
    </style>
</head>

<body>
    <div class="box">
        <button id="btn"> ×</button>
        <img src="images/er.webp" alt="" id="er">
    </div>
    <script>
        //获取元素
        var btn = document.getElementById('btn');
        var box = document.querySelector('.box');
        // 注册事件 处理程序
        btn.onclick = function () {
            box.style.display = 'none';
        }
    </script>
</body>

</html>